package com.kjtpay.design_pattern.strategy;

class CashContext {
    private CashSuper cashSuper = null;

    // 根据文字创建，相当于简单工厂
    CashContext(String type) {
        switch (type) {
            case "正常收费":
                cashSuper = new CashNormal();
                break;
            case "满300返100":
                cashSuper = new CashReturn(300, 100);
                break;
            case "打8折":
                cashSuper = new CashRebate(0.8);
                break;
            default:
                cashSuper = new CashNormal();
                break;
        }
    }

    public double getResult(double money) {
        return cashSuper.acceptCash(money);
    }
}
